function change(option) {
    var area = (typeof option.area == "undefined") ? jQuery("") : option.area; 			//鼠标经过停止自动播放的区域
    var box = (typeof option.box == "undefined") ? jQuery("") : option.box; 					//包含项目的容器
    var btn = (typeof option.btn == "undefined") ? jQuery("") : option.btn; 				//包含焦点按钮的容器
    var leftBtn = (typeof option.leftBtn == "undefined") ? jQuery("") : option.leftBtn; 	//左按钮
    var rightBtn = (typeof option.rightBtn == "undefined") ? jQuery("") : option.rightBtn; //右按钮
    var waitTime = (typeof option.waitTime == "undefined") ? 8000 : option.waitTime; 		//切换间隔时间
    var fadeTime = (typeof option.fadeTime == "undefined") ? "slow" : option.fadeTime; 	//淡入淡出时间
    var autoPlay = (typeof option.autoPlay == "undefined") ? true : option.autoPlay; 		//是否自动播放

    var listNum = box.find("li").length; //当前项目总数
    box.find("li").hide();
    box.find("li:first").addClass("active").show();
    btn.find("li:first").addClass("selected");


    var listWid = box.find("li").first().outerWidth(true); //单个项目的宽度（包括内外边距），每个项目的宽度必须一致
    var indexRight = 12; 							//容器后面不可见区 - 第一个项目的序号	
    var leftAllow = true; 										//防止连续点击左按钮
    var rightAllow = true;



    if (listNum <= 1) {
        btn.hide();
        autoPlay = false;

    }
    if (listNum <= 12) {
        leftAllow = false;
        rightAllow = false;
        btn.find("a.leftBtn").hide();
        btn.find("a.rightBtn").hide();
    }

    //切换
    function changeItem(k) {
        btn.find("li").removeClass("selected");
        btn.find("li").eq(k).addClass("selected");
        box.find("li").removeClass("active");
        box.find("li").eq(k).addClass("active");
        box.find("li").hide();
        box.find("li.active").fadeIn(fadeTime);

    }

    //点击左按钮
    leftBtn.click(function () {
        var e = box.find("li.active").index();
        if (e == 0) { e = listNum; }
        e = e - 1;
        changeItem(e);

        if (box.find("li.active").index() + 1 > 12) {
            if (box.find("li.active").index() >= 24) {
                if (box.find("li.active").index() >= 36) {
                    btn.find("ul").animate({ marginLeft: -((box.find("li.active").index() % 12 + 1) * 86 + 2064) + "px" });
                } else {
                    btn.find("ul").animate({ marginLeft: -((box.find("li.active").index() % 12 + 1) * 86 + 1032) + "px" });

                }

            } else {
                btn.find("ul").animate({ marginLeft: -(box.find("li.active").index() % 12 + 1) * 86 + "px" });

            }
        }



        if (box.find("li.active").index() == 0) {

            btn.find("ul").animate({ marginLeft: (e) * 86 + "px" });

        }




    });

    //点击右按钮
    rightBtn.click(function () {
        var e = box.find("li.active").index();
        if (e == listNum - 1) { e = -1; }
        e = e + 1;
        changeItem(e);
        if (box.find("li.active").index() + 1 > 12) {


            if (box.find("li.active").index() >= 24) {
                if (box.find("li.active").index() >= 36) {
                    btn.find("ul").animate({ marginLeft: -((box.find("li.active").index() % 12 + 1) * 86 + 2064) + "px" });
                } else {
                    btn.find("ul").animate({ marginLeft: -((box.find("li.active").index() % 12 + 1) * 86 + 1032) + "px" });

                }

            } else {

                btn.find("ul").animate({ marginLeft: -(box.find("li.active").index() % 12 + 1) * 86 + "px" });

            }
        }
        if (box.find("li.active").index() == 0) {

            btn.find("ul").animate({ marginLeft: (e) * 86 + "px" });

        }

    });

    //点击焦点按钮
    btn.find("li").click(function () {
        var e = jQuery(this).index();
        changeItem(e);
    });

    //自动播放
    function autoRun() {
        var e = box.find("li.active").index();
        if (e == listNum - 1) { e = -1; }
        e = e + 1;
        changeItem(e);
    }

    if (autoPlay) {
        var intID = setInterval(autoRun, waitTime);
        area.hover(function () {
            clearInterval(intID);
        }, function () {
            intID = setInterval(autoRun, waitTime);
        });
    }

}
/*-------------------------------------------------------------------------------------------------------------------------------*/
$(function () {
    var slideDiv = $("#bannerImg");
    var imgWid = slideDiv.find("img").width();
    setWidth();
    function setWidth() {
        var screenWid = $(window).width();
        var hideWid = (screenWid - imgWid) / 2;
        var hideWidSmall = (980 - imgWid) / 2;
        if (screenWid >= imgWid) {
            slideDiv.css({ "width": imgWid + "px", "margin": "0 auto" });
        } else {
            if (screenWid > 980) {
                slideDiv.css({ "width": screenWid + "px", "overflow": "hidden" });
                slideDiv.find("li").css({ "width": screenWid + "px", "overflow": "hidden" });
                slideDiv.find("img").css("margin-left", hideWid + "px");
            } else {
                slideDiv.css({ "width": "980px", "overflow": "hidden" });
                slideDiv.find("li").css({ "width": "980px", "overflow": "hidden" });
                slideDiv.find("img").css("margin-left", hideWidSmall + "px");
            }
        }
    }

    $(window).resize(function () {
        setWidth();
    });

});

//切换
$(function () {
    change({
        area: $("#bannerBox"), 			//鼠标经过停止自动播放的区域
        box: $("#bannerImg"), 				//包含项目的容器
        btn: $("#bannerBtn"), 				//包含焦点按钮的容器
        leftBtn: $("#bannerBox a.leftBtn"), 	//左按钮
        rightBtn: $("#bannerBox a.rightBtn"), 	//右按钮
        waitTime: 8000, 					//切换间隔时间
        fadeTime: 500, 					//淡入淡出时间
        autoPlay: true							//是否自动播放
    });
});
function bannerBtn(){
        var bannerBtnWid=$("#bannerBtn ul").width();
        var bannerBtnbox=$("#bannerBtn").width();
        $("#bannerBtn ul").css("margin-left",(bannerBtnbox - bannerBtnWid)/2 + "px");
        };
$(function(){
    bannerBtn();
});


/*----------------------------------------------------------------上下滚动-----------------------------------------------------------*/
function scrollUp(area, box, leftBtn, rightBtn, showNum, waitTime, animateTime, easing, autoPlay) {
    var config = {
        area: $(area),                	//鼠标移入停止自动播放的层
        box: $(box), 				//包含ul那个div
        leftBtn: $(leftBtn),        	//左按钮
        rightBtn: $(rightBtn),      	//右按钮
        showNum: showNum, 			//容器显示的图片个数
        waitTime: waitTime,   			//间隔时间
        animateTime: animateTime,      	//滚动效果时间
        easing: easing, 			//滚动效果
        autoPlay: autoPlay, 		//是否自动播放	
        leftAllow: true,    			//为了防止连续点击左按钮
        rightAllow: true    			//为了防止连续点击右按钮		
    }

    //小于容器显示的图片个数，就不滚动
    if (config.box.find("li").length < config.showNum) {
        config.leftAllow = false; config.rightAllow = false;
    } else {
        var listLen = config.box.find("li").length;
        //复制全部li插入到ul最后面
        config.box.find("li").clone().appendTo(config.box.find("ul"));
        //复制全部li插入到ul的最前面
        config.box.find("li").clone().prependTo(config.box.find("ul"));
        for (i = 0; i < listLen; i++) {
            config.box.find("li").last().remove();
        }
        //设置ul的左外边距初始位置
        config.box.find("ul").css("margin-top", -config.box.find("li").outerHeight(true) * listLen + "px");
    }

    //向上滚动
    config.rightBtn.click(function () { autoScroll(); });
    function autoScroll() {
        if (config.rightAllow) {
            var marTop = parseInt(config.box.find("ul").css("margin-top"), 10);
            var imgWid = config.box.find("li").outerHeight(true);
            config.rightAllow = false;
            config.box.find("ul").animate({ marginTop: marTop - imgWid + "px" }, config.animateTime, easing, function () {
                marTop = parseInt(config.box.find("ul").css("margin-top"), 10);
                var len = config.box.find("li").length;
                var mar = (config.showNum - listLen) * imgWid + "px";
                if (marTop == (config.showNum - len) * imgWid) { config.box.find("ul").css("margin-top", mar); }
                config.rightAllow = true;
            });
        }
    }

    //向下滚动
    config.leftBtn.click(function () {
        if (config.leftAllow) {
            var marTop = parseInt(config.box.find("ul").css("margin-top"), 10);
            var imgWid = config.box.find("li").outerHeight(true);
            config.leftAllow = false;
            if (marTop == 0) { config.box.find("ul").css("margin-top", -listLen * imgWid + "px"); }
            marTop = parseInt(config.box.find("ul").css("margin-top"), 10);
            config.box.find("ul").animate({ marginTop: marTop + imgWid + "px" }, config.animateTime, easing, function () {
                marTop = parseInt(config.box.find("ul").css("margin-top"), 10);
                var len = config.box.find("li").length;
                var mar = -listLen * imgWid + "px";
                if (marTop == 0) { config.box.find("ul").css("margin-top", mar); }
                config.leftAllow = true;
            });
        }
    });

    //自动播放
    if (config.autoPlay) {
        var intID = setInterval(autoScroll, config.waitTime);
        config.area.hover(function () {
            clearInterval(intID);
        }, function () {
            intID = setInterval(autoScroll, config.waitTime);
        });
    }

}
/*----------------------------------------------------------------上下滚动 - 结束--------------------------------------------------------*/

$(function () {
    scrollUp(
		".announcement", 						//鼠标移入停止自动播放的层
		".announcement .sup_box", 		//包含滚动图片的那个div
		".announcement a.leftBtn", 			//左按钮
		".announcement a.rightBtn", 			//左按钮
		1, 								//容器显示的图片个数
		5000, 							//间隔时间
		"normal", 						//滚动效果时间
		"", 								//滚动效果
		true								//是否自动播放
	);
});

/*------*/
//取子栏目
function GetChildClass(obj1, obj2) {
    $.ajax({
        type: "POST",
        url: "Ajax/Ajax_GetChildClass.ashx",
        data: "ParentID=" + $(obj1).val() + "&rnd=" + Math.round(Math.random() * 500),
        beforeSend:
			function () {
			},
        success:
			function (data) {
			    $(obj2).empty();
			    $(obj2).append(data);
			}
    });
}

//取子地区
function GetChildArea(obj1, obj2) {
    $.ajax({
        type: "POST",
        url: "Ajax/Ajax_GetChildArea.ashx",
        data: "ParentID=" + $(obj1).val() + "&rnd=" + Math.round(Math.random() * 500),
        beforeSend: function () {
        },
        success: function (data) {
            $(obj2).empty();
            $(obj2).append(data);
        }
    });
}


//搜索
function Search() {
    if ($("#SearchKey").val() == "") {
        alert("请输入搜索关键字!");
        $("#SearchKey").focus();
        return false;
    }
}